package cn.tx.shiro.exception;

import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 描述
 * @Author：XiaoBing
 * @Date：2020/11/2 17:48
 * @Version：1.0
 */
@RestControllerAdvice //以json格式返回
public class GlobalException {
    @ExceptionHandler(value = {UnauthorizedException.class})
    public Map<String, Object> unauthorized() {
        Map<String, Object> map = new HashMap<>();
        map.put("code", 302);
        map.put("msg", "-------当前用户没有权限！-------");
        System.out.println("当前用户没有权限！");
        return map;
    }
}
